/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFOfflineSource
  \brief to process offline data, an abstract base class
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-09-28
  \date 2024-06-19 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-09-28   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFOfflineSource_h
#define ETFOfflineSource_h

#include <unordered_map>
#include "ETFSource.h"

using std::unordered_map;

class ETFUnpacker;

class ETFOfflineSource : public ETFSource{
public:
  ETFOfflineSource();
  virtual ~ETFOfflineSource();

  virtual bool ReadEvent(unsigned i = 0) override; ///< read event i, true: success
  virtual void Close() override; ///< close the input file

  virtual void AddDataFile(const string &file);
  virtual void SetDebug(bool opt = true) override; ///< set unpacker debug status
  /// \param isStop: whether to issue an error if returning false
  static bool IsPXIFile(const string &file, bool isStop = false);
  static bool IsVMEFile(const string &file, bool isStop = false);
  /// \param rest in us, sleep time per event - for debugging and test purposes
  void OnlineSim(int rest_us = 0); ///< output to feed an online for test purposes

  // ClassDefOverride(ETFOfflineSource, 0); ///< to process offline data

protected:
  unordered_map<ETFUnpacker *, FILE *> fMap; ///< map of unpacker and its data file
  int fRestOnlineSim; //! ///< in us, sleep time per event - for debugging and test purposes
};

#endif
